package com.orientsec.autotest.project.system.autoRequesset.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.orientsec.autotest.framework.aspectj.lang.annotation.Log;
import com.orientsec.autotest.framework.aspectj.lang.enums.BusinessType;
import com.orientsec.autotest.project.system.autoRequesset.domain.AutoRequesset;
import com.orientsec.autotest.project.system.autoRequesset.service.IAutoRequessetService;
import com.orientsec.autotest.framework.web.controller.BaseController;
import com.orientsec.autotest.framework.web.page.TableDataInfo;
import com.orientsec.autotest.framework.web.domain.AjaxResult;
import com.orientsec.autotest.common.utils.poi.ExcelUtil;

/**
 * 请求功能设置信息操作处理
 * 
 * @author autotest
 * @date 2020-01-15
 */
@Controller
@RequestMapping("/system/autoRequesset")
public class AutoRequessetController extends BaseController
{
    private String prefix = "system/autoRequesset";
	
	@Autowired
	private IAutoRequessetService autoRequessetService;
	
	@RequiresPermissions("system:autoRequesset:view")
	@GetMapping()
	public String autoRequesset()
	{
	    return prefix + "/autoRequesset";
	}
	
	/**
	 * 查询请求功能设置列表
	 */
	@RequiresPermissions("system:autoRequesset:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(AutoRequesset autoRequesset)
	{
		startPage();
        List<AutoRequesset> list = autoRequessetService.selectAutoRequessetList(autoRequesset);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出请求功能设置列表
	 */
	@RequiresPermissions("system:autoRequesset:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(AutoRequesset autoRequesset)
    {
    	List<AutoRequesset> list = autoRequessetService.selectAutoRequessetList(autoRequesset);
        ExcelUtil<AutoRequesset> util = new ExcelUtil<AutoRequesset>(AutoRequesset.class);
        return util.exportExcel(list, "autoRequesset");
    }
	
	/**
	 * 新增请求功能设置
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存请求功能设置
	 */
	@RequiresPermissions("system:autoRequesset:add")
	@Log(title = "请求功能设置", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(AutoRequesset autoRequesset)
	{		
		return toAjax(autoRequessetService.insertAutoRequesset(autoRequesset));
	}

	/**
	 * 修改请求功能设置
	 */
	@GetMapping("/edit/{requestSeqId}")
	public String edit(@PathVariable("requestSeqId") Integer requestSeqId, ModelMap mmap)
	{
		AutoRequesset autoRequesset = autoRequessetService.selectAutoRequessetById(requestSeqId);
		mmap.put("autoRequesset", autoRequesset);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存请求功能设置
	 */
	@RequiresPermissions("system:autoRequesset:edit")
	@Log(title = "请求功能设置", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(AutoRequesset autoRequesset)
	{		
		return toAjax(autoRequessetService.updateAutoRequesset(autoRequesset));
	}
	
	/**
	 * 删除请求功能设置
	 */
	@RequiresPermissions("system:autoRequesset:remove")
	@Log(title = "请求功能设置", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(autoRequessetService.deleteAutoRequessetByIds(ids));
	}
	
}
